<template>
  <div class="coupon-card" :class="{ expired: coupon.status === 'expired' }">
    <div class="coupon-amount">
      <span class="currency">¥</span>
      <span class="number">{{ coupon.amount }}</span>
    </div>
    <div class="coupon-info">
      <h3 class="coupon-title">{{ coupon.title }}</h3>
      <p class="coupon-condition">{{ coupon.condition }}</p>
      <p class="coupon-validity">有效期至：{{ coupon.validUntil }}</p>
    </div>
    <div class="coupon-status">
      <span :class="statusClass">{{ statusText }}</span>
    </div>
  </div>
</template>

<script setup>
import { computed } from 'vue'

const props = defineProps({
  coupon: {
    type: Object,
    required: true
  }
})

const statusClass = computed(() => {
  return {
    'status-valid': props.coupon.status === 'valid',
    'status-expired': props.coupon.status === 'expired',
    'status-used': props.coupon.status === 'used'
  }
})

const statusText = computed(() => {
  const statusMap = {
    valid: '可使用',
    expired: '已过期',
    used: '已使用'
  }
  return statusMap[props.coupon.status]
})
</script>

<style scoped>
.coupon-card {
  display: flex;
  background: #fff;
  border-radius: 8px;
  padding: 15px;
  margin-bottom: 15px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.coupon-amount {
  display: flex;
  align-items: center;
  color: #ff6b81;
  padding-right: 15px;
  border-right: 1px dashed #eee;
}

.currency {
  font-size: 16px;
}

.number {
  font-size: 32px;
  font-weight: bold;
}

.coupon-info {
  flex: 1;
  padding: 0 15px;
}

.coupon-title {
  margin: 0 0 8px;
  font-size: 16px;
}

.coupon-condition,
.coupon-validity {
  margin: 5px 0;
  font-size: 12px;
  color: #666;
}

.coupon-status {
  display: flex;
  align-items: center;
}

.status-valid {
  color: #67c23a;
}

.status-expired,
.status-used {
  color: #909399;
}

@media (max-width: 768px) {
  .coupon-card {
    flex-direction: column;
    padding: 10px;
  }
  
  .coupon-amount {
    border-right: none;
    border-bottom: 1px dashed #eee;
    padding-bottom: 10px;
    margin-bottom: 10px;
  }
}
</style> 